

/***
 * @Date            : 2025-04-16 00:05:20
 * @Author          : AnimateX(Baron)
 * @LastEditors     : AnimateX(Baron)
 * @LastEditTime    : 2025-04-16 00:05:32
 * @FilePath        : /common/version.h
 * @CopyRight       : Copyright (c) 2024 RockChip Technology Co. Ltd. All rights reserved.
 * @Description     :
 */

#pragma once
#include <cstdint>
#include <string>


#define LIB_VERSION_MAJOR 1
#define LIB_VERSION_MINOR 0
#define LIB_VERSION_PATCH 0


#define COMPILE_TIME_STRING \
    "(compile " __TIME__ " " __DATE__ " )"


#define STRINGIZE(n) #n
#define VERSION_STRING(major, minor, patch) \
    STRINGIZE(major) "." STRINGIZE(minor) "." STRINGIZE(patch)


#define LIB_VERSION_INFO "rcversion " VERSION_STRING(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH) " compile time " COMPILE_TIME_STRING


extern const char libraryVersionInfo[];


struct Version {
    uint16_t    major;
    uint16_t    minor;
    uint16_t    patch;

    Version(uint16_t maj, uint16_t min, uint16_t pat)
        : major(maj), minor(min), patch(pat) {}

    bool operator<(const Version& other) const {
        if (major != other.major) return major < other.major;
        if (minor != other.minor) return minor < other.minor;
        return patch < other.patch;
    }

    bool operator==(const Version& other) const {
        return major == other.major && minor == other.minor && patch == other.patch;
    }

    static Version getVersion() {
        return Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH);
    }

    std::string getVersionString() {
        return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch) + " " + COMPILE_TIME_STRING;
    }
};
